<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/layouts/basic.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title> ${config.webTitle} </title>
    <link href="${ctx }/css/base.css" rel="stylesheet">
    <link href="${ctx }/css/index.css" rel="stylesheet">
</head>
<body>
<jsp:include page="../index/header.jsp"/>
<header>
    <div id="logo"><a href="${ctx }/"></a></div>
</header>
<jsp:include page="../index/slider.jsp"></jsp:include>
<article>
    <div class="bloglist left">
        <c:forEach items="${list}" var="vo">
            <c:if test="${!empty list}">
                <h2 class="title_tj">
                    <p><span>${vo.menu.name}</span></p>
                </h2>
                <c:forEach items="${vo.articles }" var="item">
                    <div><h3><a href="${ctx }/article/detail.do?id=${item.article.recordId}">${item.article.title }</a>
                    </h3>
                        <figure><img src="${config.adminUrl }titleImg/${item.article.titleImg}"
                                     onerror="this.src='${ctx }/images/001.png'"></figure>
                        <ul>
                            <p><itfarm:StringCut length="250"
                                                 strValue="${item.article.content }"></itfarm:StringCut></p>
                            <a title="/" href="${ctx }/article/detail.do?id=${item.article.recordId}" class="readmore">阅读全文>></a>
                        </ul>
                        <p class="dateview">
                            <span>${item.lastDate }</span><span>作者：${item.authorName }</span><span>分类：[<a
                                href="/news/life/">${item.categoryName }</a>]</span><span>浏览：( <a>${item.article.pageView }</a> )</span>
                            <span>
                    <c:if test="${user==null || !fn:contains(favoriteIds, item.article.recordId)}">
                        <a class="add_favorite" article_id="${item.article.recordId}"
                           onclick="addFavorite(${item.article.recordId}, this)">收藏</a>
                    </c:if>
                    <c:if test="${user!=null && fn:contains(favoriteIds, item.article.recordId)}">
                        <a class="add_favorite" article_id="${item.article.recordId}">已收藏</a>
                    </c:if>
                </span>
                        </p>
                    </div>
                </c:forEach>
                <br/>
            </c:if>
        </c:forEach>
    </div>
    <jsp:include page="../index/right.jsp"></jsp:include>
</article>

<footer>
    <p>Design by WindyDriven <a href="http://user.qzone.qq.com/812908087/" title="WindyDriven" target="_blank">WindyDriven</a>
        <a href="/">网站统计</a></p>
</footer>
<script src="${ctx }/js/silder.js"></script>
<script type="text/javascript">
    function addFavorite(id, o) {
        $.post('${ctx}/favorite/addFavorite.do', {id: id}, function (data) {
            alert(data.resultMessage);
            if (data.success) {
                $(o).text("已收藏");
                $(o).removeAttr('href');
                $(o).removeAttr('onclick');
            }
        })
    }
</script>
</body>
</html>